package com.lihh.demo;

import java.util.concurrent.*;

public class ThenAcceptBothTest001
{
    public static void main(String[] args) throws ExecutionException, InterruptedException
    {
        ExecutorService executors = Executors.newSingleThreadExecutor();

        CompletableFuture<String> uCompletableFuture = CompletableFuture.supplyAsync(() -> {
            System.out.println("这是执行A");
            try {
                TimeUnit.SECONDS.sleep(3);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            return "a";
        }, executors);

        CompletableFuture<Void> voidCompletableFuture = uCompletableFuture.thenAcceptAsync(res -> {
            System.out.println("这是线程B");
            System.out.println(res);
        });

        voidCompletableFuture.thenRun(() -> {
            System.out.println("这是线程C");
        });
    }
}
